package com.whl.sm.common.handler;


import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class CommonMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("createTime", new Date(), metaObject);
        this.setFieldValByName("updateTime", new Date(), metaObject);
        this.setFieldValByName("publishTime", new Date(), metaObject);
        this.setFieldValByName("regDate", new Date(), metaObject);
        this.setFieldValByName("isDelete", 0, metaObject);
        this.setFieldValByName("isDel", 0, metaObject);
    }
    @Override
    public void updateFill(MetaObject metaObject) {

        this.setFieldValByName("updateTime", new Date(), metaObject);
        this.setFieldValByName("publishTime", new Date(), metaObject);
    }

}
